﻿using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace DbUpgrader.Core
{
    public static class DbUpgraderExtensions
    {
        public static IEnumerable<string> ReadLines(Stream stream,
                                                    Encoding encoding)
        {
            using (var reader = new StreamReader(stream, encoding))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    yield return line;
                }
            }
        }

        public static void Upgrade(this DBUpgrader dbUpgrader, Stream requestContent)
        {
            dbUpgrader.Upgrade(ReadLines(requestContent, Encoding.ASCII).ToArray());
        }
    }
}